import request from '@/utils/request'

// 查询课程列表
export function getCourseList() {
  return request({
    url: '/course/startCourse/list',
    method: 'get'
  });
}

// 查询课程上课状态
export function getCourseStartStatus(courseId) {
  return request({
    url: '/course/startCourse/startStatus/' + courseId,
    method: 'get'
  })
}

// 新增课程的上课记录
export function addCourseRecord(courseId) {
  return request({
    url: '/course/startCourse/start',
    method: 'post',
    params: {
      courseId: courseId
    }
  })
}

// 结束课程的上课记录
export function endCourseRecord(courseId) {
  return request({
    url: '/course/startCourse/end',
    method: 'put',
    params: {
      courseId: courseId
    }
  })
}

// 查询课程学生列表列表
export function listCourseStudents(query, courseId) {
  // 合并 query 对象和 courseId 到一个新的参数对象中
  const params = {
    ...query,
    courseId: courseId
  };

  return request({
    url: '/course/startCourse/courseStudents/list',
    method: 'get',
    params: params
  });
}

// 查询课程学生列表详细
export function getCourseStudents(courseId) {
  return request({
    url: '/course/startCourse/courseStudents/' + courseId,
    method: 'get'
  })
}

// 新增课程学生列表
export function addCourseStudents(data) {
  return request({
    url: '/course/startCourse/courseStudents',
    method: 'post',
    data: data
  })
}

// 修改课程学生列表
export function updateCourseStudents(data) {
  return request({
    url: '/course/startCourse/courseStudents',
    method: 'put',
    data: data
  })
}

// 删除课程学生列表
export function delCourseStudents(courseId, userIds) {
  return request({
    url: '/course/startCourse/courseStudents',
    method: 'delete',
    data: {
      courseId,
      userIds
    }
  });
}
